<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统服务优先级配置指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .first-letter::first-letter {
            font-size: 3em;
            font-weight: 700;
            float: left;
            line-height: 1;
            margin-right: 0.1em;
            color: #667eea;
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        .highlight-box {
            background: linear-gradient(to right, #f3f4f6, #ffffff);
            border-left: 4px solid #667eea;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="gradient-bg text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">分布式系统服务优先级配置</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">掌握注册中心的优先级策略，优化服务路由与负载均衡</p>
            <div class="flex items-center space-x-6 text-lg">
                <span><i class="fas fa-network-wired mr-2"></i>分布式架构</span>
                <span><i class="fas fa-balance-scale mr-2"></i>负载均衡</span>
                <span><i class="fas fa-cogs mr-2"></i>服务治理</span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                    理解服务优先级
                </h2>
                <p class="text-lg text-gray-700 leading-relaxed first-letter">
                    在分布式系统中，注册中心管理着多个服务实例，并确保服务发现和负载均衡的顺畅进行。配置服务的优先级涉及到如何在多个相同服务实例中确定优先级，以便决定请求路由到哪个服务实例。服务优先级通常用于在多个相同服务实例中选择最合适的实例来处理请求，优先级的配置可以影响请求的路由决策，从而优化系统性能和资源利用率。
                </p>
            </div>
        </section>

        <!-- Visual Architecture Diagram -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-project-diagram text-purple-500 mr-3"></i>
                    服务优先级架构图
                </h2>
                <div class="mermaid">
                    graph TB
                        A[客户端请求] --> B[负载均衡器]
                        B --> C{优先级策略}
                        C -->|高优先级| D[服务实例1<br/>优先级: 高]
                        C -->|中优先级| E[服务实例2<br/>优先级: 中]
                        C -->|低优先级| F[服务实例3<br/>优先级: 低]
                        D --> G[注册中心]
                        E --> G
                        F --> G
                        G --> H[健康检查]
                        H --> I[动态调整]
                        I --> C
                </div>
            </div>
        </section>

        <!-- Configuration Methods -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-10 text-center text-gray-800 serif-font">配置服务优先级的方式</h2>
            
            <!-- Eureka Configuration -->
            <div class="mb-12">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="gradient-bg p-6">
                        <h3 class="text-2xl font-bold text-white flex items-center">
                            <i class="fas fa-cloud mr-3"></i>
                            Eureka 配置方案
                        </h3>
                    </div>
                    <div class="p-8">
                        <div class="mb-6">
                            <h4 class="text-xl font-semibold mb-3 text-gray-800">
                                <i class="fas fa-weight text-blue-500 mr-2"></i>
                                实例权重配置
                            </h4>
                            <p class="text-gray-700 mb-4">通过在服务实例注册时设置权重，在自定义负载均衡策略中实现优先级控制。</p>
                            <div class="code-block p-4">
                                <pre><code>ribbon:
  NFLoadBalancerRuleClassName: com.netflix.loadbalancer.WeightBasedRule
  ServerListRefreshInterval: 30000
  WeightBasedRule:
    - service1: 1
    - service2: 2</code></pre>
                            </div>
                        </div>
                        
                        <div class="highlight-box p-4 rounded-lg">
                            <p class="text-gray-700">
                                <i class="fas fa-info-circle text-blue-500 mr-2"></i>
                                <strong>提示：</strong>虽然Eureka本身不直接支持权重，但可以通过自定义负载均衡规则实现优先级控制。
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Consul Configuration -->
            <div class="mb-12">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="gradient-bg p-6">
                        <h3 class="text-2xl font-bold text-white flex items-center">
                            <i class="fas fa-server mr-3"></i>
                            Consul 配置方案
                        </h3>
                    </div>
                    <div class="p-8">
                        <div class="mb-6">
                            <h4 class="text-xl font-semibold mb-3 text-gray-800">
                                <i class="fas fa-tags text-green-500 mr-2"></i>
                                标签和健康检查
                            </h4>
                            <p class="text-gray-700 mb-4">通过标签和健康检查的优先级来影响服务实例的选择。</p>
                            <div class="code-block p-4">
                                <pre><code>{
  "ID": "my-service",
  "Service": {
    "Name": "my-service",
    "Tags": ["priority:high"],
    "Address": "127.0.0.1",
    "Port": 8080
  },
  "Check": {
    "http": "http://127.0.0.1:8080/health",
    "interval": "10s"
  }
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Kubernetes Configuration -->
            <div class="mb-12">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="gradient-bg p-6">
                        <h3 class="text-2xl font-bold text-white flex items-center">
                            <i class="fas fa-dharmachakra mr-3"></i>
                            Kubernetes 配置方案
                        </h3>
                    </div>
                    <div class="p-8">
                        <div class="mb-6">
                            <h4 class="text-xl font-semibold mb-3 text-gray-800">
                                <i class="fas fa-route text-orange-500 mr-2"></i>
                                Service和Ingress配置
                            </h4>
                            <p class="text-gray-700 mb-4">通过配置Ingress或Service的负载均衡策略实现优先级控制。</p>
                            <div class="code-block p-4">
                                <pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
    - host: myservice.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-service
                port:
                  number: 80</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Best Practices -->
        <section class="mb-16">
            <div class="bg-gradient-to-r from-purple-50 to-blue-50 rounded-xl p-8">
                <h2 class="text-3xl font-bold mb-8 text-gray-800 text-center">
                    <i class="fas fa-star text-yellow-500 mr-3"></i>
                    最佳实践与注意事项
                </h2>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white rounded-lg p-6 shadow-md card-hover">
                        <div class="text-center mb-4">
                            <i class="fas fa-sync-alt text-4xl text-blue-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3 text-center">一致性保证</h3>
                        <p class="text-gray-700">确保优先级配置在整个系统中保持一致，避免负载不均或服务不可用的问题。</p>
                    </div>
                    <div class="bg-white rounded-lg p-6 shadow-md card-hover">
                        <div class="text-center mb-4">
                            <i class="fas fa-heartbeat text-4xl text-red-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3 text-center">健康检查</h3>
                        <p class="text-gray-700">优先级配置应与健康检查机制结合使用，确保选中的实例处于健康状态。</p>
                    </div>
                    <div class="bg-white rounded-lg p-6 shadow-md card-hover">
                        <div class="text-center mb-4">
                            <i class="fas fa-chart-line text-4xl text-green-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3 text-center">动态调整</h3>
                        <p class="text-gray-700">根据业务需求和负载情况，动态调整服务的优先级或权重，优化系统性能。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-bookmark text-indigo-500 mr-3"></i>
                    核心要点总结
                </h2>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-green-500 text-xl mr-3 mt-1"></i>
                        <div>
                            <h4 class="font-semibold text-gray-800 mb-2">多样化的配置方式</h4>
                            <p class="text-gray-700">不同的注册中心提供了各自的优先级配置机制，需要根据具体场景选择合适的方案。</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-green-500 text-xl mr-3 mt-1"></i>
                        <div>
                            <h4 class="font-semibold text-gray-800 mb-2">灵活的扩展能力</h4>
                            <p class="text-gray-700">通过自定义负载均衡规则和策略，可以实现更加精细化的优先级控制。</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-green-500 text-xl mr-3 mt-1"></i>
                        <div>
                            <h4 class="font-semibold text-gray-800 mb-2">与健康检查结合</h4>
                            <p class="text-gray-700">优先级配置必须与健康检查机制配合